//Jen Anderson
//CS 362
//Assignment 3
//unittest2.c

/*----------------------------------------------------------------------
  Unit test for drawCard()
  Code borrowed heavily from testUpdateCoins() example given on 
  	blackboard
  Tests whether drawCard()
	Test 1: increments the number of cards in the user's hand 
	Test 2: decrements the number of cards in the user's deck
-----------------------------------------------------------------------*/

#include "dominion.h"
#include "dominion_helpers.h"
#include <string.h>
#include <stdio.h>
#include <assert.h>
#include "rngs.h"
#include <stdlib.h>

// set NOISY_TEST to 0 to remove printfs from output
#define NOISY_TEST 1

void testDrawCard() 
{
	//Initialize a test game and a compare game
        int k[10] = {adventurer, council_room, feast, gardens, mine,remodel, smithy, village, baron, great_hall};
        struct gameState *game = newGame();
        initializeGame(3, k, 10, game);
        struct gameState *testGameState = malloc(sizeof(struct gameState));
        memcpy(testGameState, game, sizeof(struct gameState));
	
	/**********
 	* Test 1 
 	**********/
	//Draw a card then make sure there's an additional card in the hand
	drawCard(0, testGameState);
	assert(testGameState->handCount[0] == game->handCount[0]+1);
	#if (NOISY_TEST == 1)
		printf("drawCard() successfully incremented the cards in Player 1's hand.\n");
	#endif
   
	/********
  	* Test 2
  	********/	
	//Draw card called in test 1
	//Make sure the deck count is decremented by 1	
	assert(testGameState->deckCount[0] == game->deckCount[0]-1);
	#if (NOISY_TEST == 1)
		printf("drawCard() successfully decremented the cards in Player 1's deck.\n");
	#endif
}

int main()
{
	testDrawCard();
	return 0;
}
